﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IRC.IRepairClouds.DataLayer.Cache;
using System.Data.Objects.DataClasses;

namespace IRC.IRepairClouds.DataLayer
{
    public static partial class EntityCached
    {
        public static ETimeZone CachedETimeZone(this ICloudRepairEntities dbContext, int id)
        {
            return CreateCached(dbContext, i => i.TimeZone, i => i.TimeZoneId, id);
        }

        public static ETimeZone CachedEMailTemplate(this ICloudRepairEntities dbContext, ETimeZone entity)
        {
            return CachedETimeZone(dbContext, entity.TimeZoneId);
        }

        public static ETimeZone CachedEntity(this EntityReference<ETimeZone> entityReference, ICloudRepairEntities dbContext)
        {
            return CachedETimeZone(dbContext, entityReference.GetKey());
        }

        public static TimeZoneCached Cached(this EntityReference<ETimeZone> entityReference)
        {
            return CacheManager.TimeZones[entityReference.GetKey()];
        }
    }
}
